package com.son.service;

import com.son.dao.InterTeacherDao;
import com.son.domin.Student;
import com.son.domin.Teacher;
import com.son.factory.TeacherFactory;

import java.util.ArrayList;

public class TeacherServiceImpl implements InterTeacherService{

    InterTeacherDao interTeacherDao= TeacherFactory.getTeacherDao();
    @Override
    public void addTeacher(Teacher teacher) {
        interTeacherDao.addTeacher(teacher);
    }

    @Override
    public boolean isExists(String sid) {
        ArrayList<Teacher> list=interTeacherDao.findAllTeacher();
        for (int i = 0; i < list.size(); i++) {
            Teacher teacher = list.get(i);
            if (teacher!=null&&teacher.getSid().equals(sid)){
                return true;
            }
        }
        return false;
    }

    @Override
    public ArrayList<Teacher> findAllTeacher() {
        ArrayList<Teacher> allTeacher = interTeacherDao.findAllTeacher();
        return allTeacher;
    }

    @Override
    public void deleteTeacher(String sid) {
        interTeacherDao.deleteTeacher(sid);
    }

    @Override
    public void updateTeacher(String sid, Teacher teacher) {
        interTeacherDao.updateTeacher(sid,teacher);
    }
}
